package com.ruoyi.energy.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.energy.mapper.TcParkingMapper;
import com.ruoyi.energy.domain.TcParking;
import com.ruoyi.energy.service.ITcParkingService;

/**
 * 车位信息Service业务层处理
 *
 * @author cjie
 * @date 2021-07-29
 */
@Service
public class TcParkingServiceImpl implements ITcParkingService {
    @Autowired
    private TcParkingMapper tcParkingMapper;

    /**
     * 查询车位信息
     *
     * @param id 车位信息ID
     * @return 车位信息
     */
    @Override
    public TcParking selectTcParkingById(String id) {
        return tcParkingMapper.selectTcParkingById(id);
    }

    /**
     * 查询车位信息列表
     *
     * @param tcParking 车位信息
     * @return 车位信息
     */
    @Override
    public List<TcParking> selectTcParkingList(TcParking tcParking) {
        return tcParkingMapper.selectTcParkingList(tcParking);
    }

    /**
     * 新增车位信息
     *
     * @param tcParking 车位信息
     * @return 结果
     */
    @Override
    public int insertTcParking(TcParking tcParking) {
        tcParking.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        tcParking.setCreateTime(DateUtils.getNowDate());
        tcParking.setCreateBy(SecurityUtils.getUsername());
        return tcParkingMapper.insertTcParking(tcParking);
    }

    /**
     * 修改车位信息
     *
     * @param tcParking 车位信息
     * @return 结果
     */
    @Override
    public int updateTcParking(TcParking tcParking) {
        tcParking.setUpdateTime(DateUtils.getNowDate());
        tcParking.setUpdateBy(SecurityUtils.getUsername());
        return tcParkingMapper.updateTcParking(tcParking);
    }

    /**
     * 批量删除车位信息
     *
     * @param ids 需要删除的车位信息ID
     * @return 结果
     */
    @Override
    public int deleteTcParkingByIds(String[] ids) {
        return tcParkingMapper.deleteTcParkingByIds(ids);
    }

    /**
     * 删除车位信息信息
     *
     * @param id 车位信息ID
     * @return 结果
     */
    @Override
    public int deleteTcParkingById(String id) {
        return tcParkingMapper.deleteTcParkingById(id);
    }
}
